{extend name="property/public/insidePageBase" /}
{block name="title"}维修工单类详情{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form  layui-form-pane">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <div class="layui-row">
                    <div class="layui-col-xs6">
                        <div class="layui-form-item">
                            <label class="layui-form-label">工单类型</label>
                            <div class="layui-input-block">
                                <input type="text"  value="{$info['full_cate_name'] ?? ''}" disabled autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs3">
                        <div class="layui-form-item">
                            <label class="layui-form-label">工单价格</label>
                            <div class="layui-input-block">
                                <input type="text" value="{$info['amount'] ?? ''}" disabled lay-verify="require" autocomplete="off"  class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs3">
                        <div class="layui-form-item">
                            <label class="layui-form-label">工单限时</label>
                            <div class="layui-input-block">
                                <input type="text" value="{$info['time_limit'] ?? ''} H" disabled lay-verify="require" autocomplete="off"  class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
                <table class="layui-hide" id="repairList" lay-filter="repairList"></table>
                <script type="text/html" id="tableRepairBar">
                    <div class="layui-btn-group">
                        {if $editRepairAuth} <a class="layui-btn layui-btn-sm  layui-btn-normal" lay-event="editRepair">编辑</a>{/if}
                        {if $detailRepairAuth}<a class="layui-btn layui-btn-sm" lay-event="detailsRepair">详情</a>{/if}
                    </div>
                </script>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
{__block__}
<script>
    let time = ''
    layui.use(['laydate','table'], function () {
        var laydate = layui.laydate, table = layui.table;
        let cateId = {$info['id']};
        // 资产列表 add
        var tableIdRepair = 'repairList';
        table.render({
            elem: '#'+tableIdRepair,
            id:tableIdRepair,
            url: '{:url("propertyRepairOrderList")}?cates_id='+cateId,
            toolbar: '#toolRepairbar',
            cols: [[
                {type: "checkbox", width: 50},
                {field: 'contact_name', width: 128, title: '联系人',sort: true},
                {field: 'contact_mobile', width: 118, title: '联系电话',sort: true},
                {field: 'hope_repair_date', width: 168, title: '预约维修时间',sort: true},
                {field: 'content', minWidth: 120,title: '工单说明', sort: true}
                {if $editRepairAuth || $delRepairAuth}
                , {title: '操作', width: 128, toolbar: '#tableRepairBar', fixed:'right'}
                {/if}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            height: 'full-120'
        });
        table.on('tool('+tableIdRepair+')', function(obj){
            var data = obj.data
            if(obj.event === 'editRepair'){
                var url = '{:url("propertyRepairOrderEdit")}?id='+data.id
                var index = layer.open({ title: '编辑工单信息',type: 2,shade: 0.2,maxmin: true, area: ['680px', '600px'], content: url, btnAlign: 'c',btn: ['确定','取消'], yes: function( index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index],submit = layero.find('iframe').contents().find("#submitBtn");
                        iframeWindow.layui.form.on('submit(submitBtn)', function(data){
                            var field = data.field //获取提交的字段
                            var loadAdd = layer.msg('提交中',{icon: 16, time: 0, shade: 0.1, offset: '15px'})
                            $.post(url, field, function(res){
                                layer.close(loadAdd)
                                if(res.code === 0) {
                                    table.reload(tableIdRepair)
                                    layer.close(index)
                                    layer.msg(res.msg, {icon:6, offset: '15px'})
                                }else {
                                    layer.msg(res.msg, {icon:5, offset: '15px'})
                                }
                            })
                        })
                        submit.trigger('click')
                    }
                })
                $(window).on("resize", function(){
                    layer.full(index)
                })
                return false
            } else if (obj.event === 'detailsRepair') {
                var url = '{:url("propertyRepairOrderDetail")}?id='+data.id;
                var index = parent.layer.open({title:data.cate_name + ' 维修工单详情 '  , type: 2, shade: 0.2, maxmin: true, shadeClose:true, move:false,area: ['980px', '100%'],offset:  'rt', anim: 2, content: url , btn:false });
                return false;
            }
        })
        // 资产列表 end
    });
</script>
{/block}